Skip to content

feat: add ansible execution environment for playbooks #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
Merged

Conversation

cardoe
Copy link
Contributor

@cardoe cardoe commented Mar 27, 2025

This creates an ansible based container that has ansible-runner as the executor inside which can then be loaded with playbooks and roles so that we can have a consistent way to configure different parts of the system or react to events in the system and execute a series of steps. To provide a consistent way to configure the overall system and react to events in the system. Some areas where this might be useful is for OpenStack Helm has a bootstrap bash script that executes on deployment. This is a big hardcoded blob and will be easier to be configurable via ansible.

@cardoe cardoe force-pushed the ansible-start branch 2 times, most recently from c30a353 to 8953184 Compare March 28, 2025 18:23
@cardoe cardoe marked this pull request as ready for review March 28, 2025 18:25
@cardoe cardoe force-pushed the ansible-start branch 4 times, most recently from 2ab114b to e26c3b0 Compare April 7, 2025 22:01
@cardoe cardoe marked this pull request as draft April 8, 2025 13:46
@cardoe cardoe force-pushed the ansible-start branch 14 times, most recently from 0a050b6 to 56ac014 Compare April 10, 2025 21:50
@cardoe cardoe requested a review from skrobul April 10, 2025 21:55
@cardoe
Copy link
Contributor Author

cardoe commented Apr 10, 2025

So this would require a ConfigMap in the openstack namespace called ansible-inventory with a key of hosts.yaml to exist. The contents would be something like:

all:
    vars:
        keystone_bootstrap_dex_url: "https://dex.dns.zone"

Copy link
Collaborator

@skrobul skrobul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM, I would probably feel better if we enforced that variables are set. Something like this should help (untested):

pre_tasks:
  - name: Fail if ENV variables are not set
    fail:
      msg: "Environment variable {{ item }} is not set. Exiting playbook."
    when: lookup('env', item) == ''
    loop:
      - DNS_ZONE
      - OS_USERNAME
      - OS_DEFAULT_DOMAIN

@cardoe cardoe requested a review from skrobul April 23, 2025 18:14
@cardoe
Copy link
Contributor Author

cardoe commented Apr 24, 2025

overall LGTM, I would probably feel better if we enforced that variables are set. Something like this should help (untested):

pre_tasks:

  - name: Fail if ENV variables are not set

    fail:

      msg: "Environment variable {{ item }} is not set. Exiting playbook."

    when: lookup('env', item) == ''

    loop:

      - DNS_ZONE

      - OS_USERNAME

      - OS_DEFAULT_DOMAIN

Good point. Should add this.

@cardoe
Copy link
Contributor Author

cardoe commented Apr 24, 2025

I started to fix the role piece upstream. The first part is to use the service proxy and have cross domain support. That PR is https://review.opendev.org/c/openstack/ansible-collections-openstack/+/947285

The ultimate bug we need to fix is https://bugs.launchpad.net/ansible-collections-openstack/+bug/2107410

@cardoe
Copy link
Contributor Author

cardoe commented Apr 24, 2025

@haseebsyed12 this is the PR that needs to be finished up and then the network piece added to it.

Another thing that might be interesting to use for bootstrapping would be https://k-orc.cloud

This creates an ansible based container that has ansible-runner as the
executor inside which can then be loaded with playbooks and roles so
that we can have a consistent way to configure different parts of the
system or react to events in the system and execute a series of steps.
To provide a consistent way to configure the overall system and react to
events in the system. Some areas where this might be useful is for
OpenStack Helm has a bootstrap bash script that executes on deployment.
This is a big hardcoded blob and will be easier to be configurable via
ansible.
@cardoe cardoe marked this pull request as ready for review April 24, 2025 14:47
@cardoe cardoe marked this pull request as draft April 24, 2025 14:47
@cardoe cardoe force-pushed the ansible-start branch 2 times, most recently from 4e34aa5 to 882247a Compare April 24, 2025 18:14
cardoe added 2 commits April 24, 2025 13:29
The current keystone bootstrap is a bash script which makes it hard to
ensure that everything has been setup. By making it Ansible we can
ensure that things are consistent. Unfortunately the openstack's role
module does not support cross-domain or inherited like the CLI does so
this hacks around it with ansible.builtin.command that then needs some
hoops to avoid lint errors. Bump the keystone chart version which fixes
volume mounts so that our inventory can be mounted into the bootstrap
container.
This value is not used anywhere.
@cardoe cardoe force-pushed the ansible-start branch 2 times, most recently from 055f49d to 9d86d74 Compare April 24, 2025 18:38
@cardoe cardoe marked this pull request as ready for review April 24, 2025 18:38
@cardoe cardoe added this pull request to the merge queue Apr 24, 2025
Merged via the queue into main with commit 7e332f3 Apr 24, 2025
25 checks passed
@cardoe cardoe deleted the ansible-start branch April 24, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants